local skel = fk.CreateSkill {
  name = "efengqi__fankui",
}

Fk:loadTranslationTable{
  ["efengqi__fankui"] = "反馈",
  [":efengqi__fankui"] = "每当你受到1点伤害后，可以获得伤害来源一张牌；若为装备牌，你可以令一名角色使用之。",

  ["#efengqi__fankui-invoke"] = "反馈：你可以获得 %dest 一张牌！",
  ["#efengqi__fankui-use"] = "反馈：你可以令一名角色使用 %arg！",

  ["$efengqi__fankui1"] = "哼，自作孽不可活！",
  ["$efengqi__fankui2"] = "哼，正中下怀！",
}

skel:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.from and not data.from.dead and not data.from:isNude()
  end,
  trigger_times = function (self, event, target, player, data)
    return data.damage
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#efengqi__fankui-invoke::"..data.from.id}) then
      event:setCostData(self, {tos = {data.from}})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if data.from:isNude() or player.dead then return end
    local cid = room:askToChooseCard(player, { target = data.from, flag = "he", skill_name = skel.name})
    room:obtainCard(player, cid, false, fk.ReasonPrey, player, skel.name)
    if not player.dead and table.contains(player:getCardIds("h"), cid) then
      Fk:filterCard(cid, player)
      local card = Fk:getCardById(cid)
      if card.type == Card.TypeEquip then
        local targets = table.filter(room.alive_players, function (p) return p:canUseTo(card, p) end)
        if #targets == 0 then return false end
        local tos = room:askToChoosePlayers(player, {
          min_num = 1, max_num = 1, targets = targets, skill_name = skel.name, prompt = "#efengqi__fankui-use:::"..card:toLogString()
        })
        if #tos > 0 then
          room:useCard{from = tos[1], tos = tos, card = card}
        end
      end
    end
  end
})



return skel
